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:
- Use a unique hash and ID for each new user session. Do not reuse hashes across users.
- Always log the user out (either due to inactivity or because the user closed the session).
- Do not generate a new Bearer Token for every request. The same token lasts 10 hours and can be reused.
- Cache the Bearer Token and proactively renew it before it expires.
- Do not send bursts of messages without throttling. Implement debounce on the front end for rapid clicks.
- Always use the same hash/ID throughout the entire conversation.
- Implement a client-side timeout for inactivity.
- Tolerate unknown plugins: ignore them without breaking the integration.
See also:
Error Mapping and Technical Considerations for the Messaging API