Marketplace
>
sendMessagesWithMessageBird
firestore

sendMessagesWithMessageBird

v
0.0.3
Latest Version
Likes
0
Installations
0
Views
0
1

Overview

Send messages with the MessageBird API when a new document is created in Firestore.

Usage

### How this function works Use this function to send omnichannel messages (SMS, WhatsApp, Google's Business Messages, Messenger, Telegram, Line, Viber, etc.) with MessageBird. The function uses the MessageBird Conversations API and will be triggered by an onCreate event when a document is written for the first time in a Firestore collection. The type of message you want to send will define which field is required within the message content. ### Prerequisites - You must have previous knowledge of **MessageBird**. - You must have previous knowledge of **Firestore**. ### Function details In order to complete the installation process, you must add the required info to the form with the following parameters from your MessageBird account: > MESSAGEBIRD_LIVE_API_KEY: The API key that MessageBird uses to identify the user. > CHANNEL_ID: The channel ID from which the message should be sent. > MESSAGEBIRD_PARAMS_RESOLVER: Map to resolve the content object of the Firestore document. The content must have the following structure depending on the message type. Here are some examples of how to use the function when it is installed. #### Example 1: Text-type message If you want to send a text-type message, suppose that the document in the specified Firestore collection has the following structure: ```JSON { "user": { "to": "1234567890", "message": { "text": "Hello World" } } } ``` Then the environment variable MESSAGEBIRD_PARAMS_RESOLVER should have a structure as follows: ```JSON { "type": "text", "to": "user.to", "content": { "text": "user.message.text", } } ``` #### Example 2: Image, video, audio, file message To send messages with images, videos, audios, or a file, you need a different JSON. Suppose that the document in the specified Firestore collection has the following structure: ```JSON { "user": { "to": "1234567890", "message": { "url": "http://example.com", "caption": "lorem ipsum" } } } ``` Then the environment variable MESSAGEBIRD_PARAMS_RESOLVER should have a structure as follows: ```JSON { "type": "image", "to": "user.to", "content": { "image": { "url": "user.message.url", "caption": "user.message.caption" }, } } ``` #### Example 3: Email If you want to send an email, suppose that the document in the specified Firestore collection has the following structure: ```JSON { "user": { "to": ["john@gmail.com"], "from": ["jane@gmail.com"], "message": { "subject": "Hello World", "text": "Lorem ipsum dolor sit amet.", } } } ``` Then the environment variable MESSAGEBIRD_PARAMS_RESOLVER should have a structure as follows: ```JSON { "type": "email", "to": "user.to", "content": { "email": { "to": "user.to", "from": "user.from", "subject": "user.message.subject", "text":"user.message.text" }, } } ``` > Note that if you need to access the body of the request and the response that the MessageBird Conversations API returns, you can do so from the function logs called messagebird_request and messagebird_response. ### Resources For more information about all the other types of messages you can send with MessageBird, see: [MessageBird Documentation](https://developers.messagebird.com/api/conversations/#send-message)
Cost
FREE
Cost
Version
0.0.3
Language
JAVASCRIPT
Created At
Updated At
Workspace
firestore
Tags
firestore
sms
message
© 2023 Function Store