Download the PHP package sendbee/api without Composer
On this page you can find all versions of the php package sendbee/api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package api
AI Number PHP API Client
Table of contents
- Installation
- Initialization
Contacts
- Fetch contacts
- Subscribe contact
- Update contact
Contact Tags
- Fetch tags
- Create tag
- Update tag
- Delete tag
Contact Fields
- Fetch contact fields
- Create contact field
- Update contact field
- Delete contact field
Conversations
- Fetch conversations
- Fetch single conversation
- Update single conversation
- Fetch messages
Teams
- Fetch teams
- Fetch team members
Messages
- Fetch message templates
- Send template message
- Send message
Automation
- Toggle bot for conversation with contact on off
- Get chatbot (automated responses) status
Mics
- Pagination
- Exception handling
- Authenticate webhook request
- Official Documentation
Installation
The recommended way to install Sendbee API is with Composer.
1. Install Composer
2. Install Sendbee API using Composer
2.a Using Composer CLI
You can add Sendbee API as a dependency using the composer.phar CLI:
2.b Using global composer CLI
If Composer is available globally on your system, you can run the following from your project root.
2.c Modifying existing composer.json
If you have an existing project that uses Composer and has composer.json
file,
you can specify sendbee/api
as a dependency.
After adding a dependency you should tell composer to update dependencies
Usage
Autoload
After installing, you need to require Composer's autoloader:
You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at Composer.
Initialization
To initialize the API client, you'll need a public key and secret. That data is available in your Sendbee dashboard.
Contacts
Fetch contacts
Subscribe contact
Update contact
Contact tags
Fetch tags
Create tag
Update tag
Delete tag
Contact fields
Fetch contact fields
Create contact field
Update contact field
Delete contact field
Conversations and messages
Fetch conversations
Fetch single conversation
update-single-conversation
Update a single conversation
Fetch messages in a conversation
Sending messages
Fetch message templates
Send template message
Send message
You can send either text message or media message.
For media message, following formats are supported:
Audio: AAC, M4A, AMR, MP3, OGG OPUS
video: MP4, 3GPP
Image: JPG/JPEG, PNG
Documents: PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX
Teams
Fetch teams
Fetch team members
Automation
Toggle bot for conversation with contact on off
Every contact is linked with conversation with an agent.
Conversation could be handled by an agent or a bot (automation).
Every time a message has been sent to a contact by an agent or using the API,
the bot is automatically turned off for that conversation - except when you set
'prevent_bot_off' to true via API call (see Send message).
Use the example below to change the chatbot status based on your use case.
Get chatbot (automated responses) status
You can also check if chatbot is turned on or off for a conversation.
Misc
Response
All API methods return a Sendbee\Api\Transport\Response
object.
Only exception is when some required parameter is missing or there are network issues - in that case an exception is thrown.
The response object wraps the raw server response into corresponding objects and exposes methods to inspect received data.
Pagination
Pagination is available on all client methods that accept a page
parameter. Those methods are:
- getContacts()
- getTags()
- getContactFields()
- getConversations()
- getMessages()
- getMessageTemplates()
To get the first page of results you can omit the page
parameter or set it to 1
Calling API methods that get a list of resources will return a Sendbee\Api\Transport\Response
object containing pagination.
Calling getMeta()
on it will return pagination information.
Exception handling
Sendbee API client for PHP will throw an Exception is some required data is missing or it is unable to connect to Sendbee. You should wrap API calls in a try-catch block and handle thrown exceptions.
You should only encounter 2 types of exceptions:
-
\Sendbee\Api\Support\DataException
- Thrown when required data is missing. Message contains more information. \GuzzleHttp\Exception\GuzzleException
- Thrown by underlying GuzzleHttp library. Indicates Sendbee backend is unavailable/unreachable
Authenticate webhook request
After activating your webhook URL in Sendbee Dashboard, we will start sending requests on that URL depending on which webhook type is linked with that webhook URL.
Every request that we make will have authorization token in header, like this:
To authenticate requests that we make to your webhook URL, take this token from request header and check it using Sendbee API Client: