The Crisp API Ruby wrapper. Authenticate, send messages, fetch conversations, access your agent accounts from your Ruby code.
Copyright 2023 Crisp IM SAS. See LICENSE for copying information.
You may follow the REST API Quickstart guide, which will get you running with the REST API in minutes.
Add the library to your Gemfile
:
gem "crisp-api", "~> 1.1.12"
Then, import it:
require "crisp-api"
Build a new authenticated Crisp client with your identifier
and key
tokens.
client = Crisp::Client.new
client.set_tier("plugin")
client.authenticate(identifier, key)
Then, your client is ready to be consumed!
To authenticate against the API, obtain your authentication token keypair by following the REST API Authentication guide. You'll get a token keypair made of 2 values.
Keep your token keypair values private, and store them safely for long-term use.
Then, add authentication parameters to your client
instance right after you create it:
client = Crisp::Client.new
# Authenticate to API with your plugin token (identifier, key)
# eg. client.authenticate("5c0595b2-9381-4a76-a2e0-04aa00c1ede7", "3bdb0812d0f5352bf68901ddc731434dade419b98507971905acdd2f967df61c")
client.set_tier("plugin")
client.authenticate(identifier, key)
# Now, you can use authenticated API sections.
Most useful available Crisp API resources are implemented. Programmatic methods names are named after their label name in the REST API Reference.
All methods that you will most likely need when building a Crisp integration are prefixed with a star symbol (β).
In the following method prototypes, crisp
is to be replaced with your Crisp API instance. For example, instanciate client = Crisp()
and then call eg: client.website.list_conversations(website_id, 1)
.
When calling a method that writes data to the API (eg. send a message with: client.website.send_message_in_conversation()
), you need to submit it this way:
website_id = "6497e4a4-b17c-41e0-bfea-eea97ba8115a"
session_id = "session_f32bc993-f7ce-41af-bcd1-110fc147a392"
client.website.send_message_in_conversation(
website_id, session_id,
{
"type" => "text",
"content" => "This message was sent from ruby-crisp-api! :)",
"from" => "operator",
"origin" => "chat"
}
)
β οΈ Note that, depending on your authentication token tier, which is either user
or plugin
, you may not be allowed to use all methods from the library. When in doubt, refer to the library method descriptions below. Most likely, you are using a plugin
token.
Website Conversations
β List Conversations [user
, plugin
]: Reference
client.website.list_conversations(website_id, page_number)
Search Conversations [user
, plugin
]: Reference
client.website.search_conversations(website_id, page_number, search_query, search_type, search_operator, include_empty, filter_unread, filter_resolved, filter_not_resolved, filter_mention, filter_assigned, filter_unassigned, filter_date_start, filter_date_end, order_date_created", order_date_updated)
Website Conversation
β Create A New Conversation [user
, plugin
]: Reference
client.website.create_new_conversation(website_id)
Check If Conversation Exists [user
, plugin
]: Reference
client.website.check_conversation_exists(website_id, session_id)
β Get A Conversation [user
, plugin
]: Reference
client.website.get_conversation(website_id, session_id)
Remove A Conversation [user
, plugin
]: Reference
client.website.remove_conversation(website_id, session_id)
Initiate A Conversation With Existing Session [user
, plugin
]: Reference
client.website.initiate_conversation_with_existing_session(website_id, session_id)
β Get Messages In Conversation [user
, plugin
]: Reference
client.website.get_messages_in_conversation(website_id, session_id, query)
β Send A Message In Conversation [user
, plugin
]: Reference
client.website.send_message_in_conversation(website_id, session_id, query)
Update A Message In Conversation [user
, plugin
]: Reference
client.website.update_message_in_conversation(website_id, session_id, fingerprint, data)
Compose A Message In Conversation [user
, plugin
]: Reference
client.website.compose_message_in_conversation(website_id, session_id, data)
β Mark Messages As Read In Conversation [user
, plugin
]: Reference
client.website.mark_messages_read_in_conversation(website_id, session_id, data)
β Mark Messages As Delivered In Conversation [user
, plugin
]: Reference
client.website.mark_messages_delivered_in_conversation(website_id, session_id, data)
β Get Conversation Routing Assign [user
, plugin
]: Reference
client.website.get_conversation_routing_assign(website_id, session_id)
β Assign Conversation Routing [user
, plugin
]: Reference
client.website.assign_conversation_routing(website_id, session_id, data)
β Get Conversation Metas [user
, plugin
]: Reference
client.website.get_conversation_metas(website_id, session_id)
β Update Conversation Metas [user
, plugin
]: Reference
client.website.update_conversation_metas(website_id, session_id, data)
List Conversation Pages [user
, plugin
]: Reference
client.website.list_conversation_pages(website_id, session_id, page_number)
List Conversation Events [user
, plugin
]: Reference
client.website.list_conversation_events(website_id, session_id, page_number)
List Conversation Files [user
, plugin
]: Reference
client.website.list_conversation_files(website_id, session_id, page_number)
Get Conversation State [user
, plugin
]: Reference
client.website.get_conversation_state(website_id, session_id)
β Change Conversation State [user
, plugin
]: Reference
client.website.change_conversation_state(website_id, session_id, data)
Get Block Status For Conversation [user
, plugin
]: Reference
client.website.get_block_status_for_conversation(website_id, session_id)
Block Incoming Messages For Conversation [user
, plugin
]: Reference
client.website.block_incoming_messages_for_conversation(website_id, session_id, data)
Request Email Transcript For Conversation [user
, plugin
]: Reference
client.website.request_email_transcript_for_conversation(website_id, session_id, data)
Website People (these are your end-users)
Get People Statistics [user
, plugin
]: Reference
client.website.get_people_statistics(website_id)
List People Segments [user
, plugin
]: Reference
client.website.list_people_segments(website_id, page_number)
β List People Profiles [user
, plugin
]: Reference
client.website.list_people_profiles(website_id, page_number)
β Add New People Profile [user
, plugin
]: Reference
client.website.add_new_people_profile(website_id, data)
β Check If People Profile Exists [user
, plugin
]: Reference
client.website.check_people_profile_exists(website_id, people_id)
β Get People Profile [user
, plugin
]: Reference
client.website.get_people_profile(website_id, people_id)
β Save People Profile [user
, plugin
]: Reference
client.website.save_people_profile(website_id, people_id, data)
Find People Profile By Email [user
, plugin
]: Reference
client.website.find_people_profile_by_email(website_id, email)
β Update People Profile [user
, plugin
]: Reference
client.website.update_people_profile(website_id, people_id, data)
β Remove People Profile [user
, plugin
]: Reference
client.website.remove_people_profile(website_id, people_id)
List People Conversations [user
, plugin
]: Reference
client.website.list_people_conversations(website_id, people_id, page_number)
Add A People Event [user
, plugin
]: Reference
client.website.add_people_event(website_id, people_id, data)
List People Events [user
, plugin
]: Reference
client.website.list_people_events(website_id, people_id, page_number)
Get People Data [user
, plugin
]: Reference
client.website.get_people_data(website_id, people_id)
Save People Data [user
, plugin
]: Reference
client.website.save_people_data(website_id, people_id, data)
Update People Data [user
, plugin
]: Reference
client.website.update_people_data(website_id, people_id, data)
Get People Subscription Status [user
, plugin
]: Reference
client.website.get_people_subscription_status(website_id, people_id)
Update People Subscription Status [user
, plugin
]: Reference
client.website.update_people_subscription_status(website_id, people_id, data)
π Notice: The peopleID
argument can be an email or the peopleID
.
Website Base
Create Website [user
, plugin
]: Reference
client.website.create_website(data)
Get A Website [user
, plugin
]: Reference
client.website.get_website(website_id)
Delete A Website [user
]: Reference
client.website.delete_website(website_id)
Website Batch
Batch Resolve Items [user
]: Reference
client.website.batch_resolve_items(website_id, data)
Batch Read Items [user
]: Reference
client.website.batch_read_items(website_id, data)
Batch Remove Items [user
]: Reference
client.website.batch_remove_items(website_id, data)
Website Availability
user
, plugin
]: Referenceclient.website.get_website_availability_status(website_id)
Website Operator
List Website Operators [user
, plugin
]: Reference
client.website.list_website_operators(website_id)
List Last Active Website Operators [user
, plugin
]: Reference
client.website.list_last_active_website_operators(website_id)
Website Settings
Get Website Settings [user
, plugin
]: Reference
client.website.get_website_settings(website_id)
Update Website Settings [user
, plugin
]: Reference
client.website.update_website_settings(website_id, data)
Website Visitors
Count Visitors [user
, plugin
]: Reference
client.website.count_visitors(website_id)
List Visitors [user
, plugin
]: Reference
client.website.list_visitors(website_id, page_number)
Get Session ID [user
, plugin
]: Reference
client.website.get_session_id_by_token(website_id, token)
user
, plugin
]: Referenceclient.bucket.generate_bucket_url(data)