Find the answer you are looking for

FAQs and Best Practices for the Messaging API

Below you’ll find answers to the most common questions about implementing the Messaging API, along with best practices to follow.

Messaging API
FAQ  
Key Facts
The bot responds as if it were the first time, but I’m in the middle of a flow. The session has likely expired. Restart the flow with the initial sentence. Always use the same `user.hash`.
I’m getting an HTTP 401 on all calls. The Bearer Token has expired. Obtain a new token by sending a POST request to `/auth` and try again. We recommend caching and proactively renewing the token.
The `text` field is empty, but there are widgets. This is normal in some cases, such as with the interactive list. Render the widgets as main content.
What should I do with the value of step-type buttons?   Never send it as a sentence. For step-type buttons, always send the LABEL.
Can I send multiple messages in parallel for the same user? No. The API is stateful. Messages must always be sent sequentially.
What happens if the user closes the app in the middle of a flow? The session remains active until it expires. If they return earlier with the same hash, they continue from where they left off. If it has expired, they must restart.
How do I test the integration without affecting production? Ask your technical team for credentials for a QA/testing environment.

✅ Best practices:

  1. Use a unique hash and ID for each new user session. Do not reuse hashes across users.
  2. Always log the user out (either due to inactivity or because the user closed the session).
  3. Do not generate a new Bearer Token for every request. The same token lasts 10 hours and can be reused.
  4. Cache the Bearer Token and proactively renew it before it expires.
  5. Do not send bursts of messages without throttling. Implement debounce on the front end for rapid clicks.
  6. Always use the same hash/ID throughout the entire conversation.
  7. Implement a client-side timeout for inactivity.
  8. Tolerate unknown plugins: ignore them without breaking the integration.

📚 See also:

Error Mapping and Technical Considerations for the Messaging API

This website stores cookies on your computer. These cookies are used to collect information about how you interact with our website and allow us to remember you. We use this information in order to improve and customize your browsing experience and for analytics and metrics about our visitors both on this website and other media. To find out more about the cookies we use, see our Privacy Policy.

If you decline, your information won’t be tracked when you visit this website. A single cookie will be used in your browser to remember your preference not to be tracked.