How to send chat messages using C# Script

This comprehensive guide walks you through the seamless process of setting up chat messaging using C# scripting within the Ozeki Chat Gateway. Whether you're a seasoned developer or just getting started, you'll learn how to quickly integrate and configure C# scripts to handle both incoming and outgoing messages. From logging in and setting up your chat account to installing and configuring the C# script application, every step is covered in detail. Discover how to automate your communication process, ensuring prompt and efficient responses without manual intervention.

What is C# script?

C# script is a form of programming using the C# language, often employed for writing and executing code snippets quickly without the need for a full application setup. It’s commonly used in scripting environments or as part of automation processes to perform tasks or manipulate data.

How to send chat messages using C# Script (Simple steps)

To send chat messages using C# Script

  1. Log in to Ozeki Chat Gateway
  2. Add new chat account
  3. Activate connection
  4. Install the C# script application
  5. Configure the C# script
  6. Define new incoming route
  7. Enter details to the incoming route
  8. Attach new outgoing route
  9. Specify details to the outgoing route
  10. Load myozeki.com
  11. Start chat conversation

Send chat messages using C# Script (Video tutorial)

In this short video, you can learn how to send messages correctly using C# script. We provide you all the essential steps you need to take, so your only task is to follow the given instructions. It will begin by installing and configuring the Ozeki Chat account, how to activate your C# script, then it will present you how to define incoming and outgoing message routes. While some basic knowledge of programming is helpful, developers of all levels will find the process understandable. By the end, you’ll be able to utilize the benefits of C# scripting to enhance your chat communication.

Step 1 - Access your Ozeki SMS Gateway account

Begin by logging into your Ozeki Chat Gateway account. If you don’t have an account, download the Ozeki Chat Gateway from https://ozeki.chat/, install the application, and create a new Ozeki account. After logging in with your credentials, you’ll be taken to the home screen of the Ozeki Chat Gateway. From there, navigate to the main interface and choose the option to add a new chat account.

Add new chat account
Figure 1 - Add new chat account

Install the Ozeki Chat Account from the connections panel to connect to the Ozeki server. This will enable you to send chat messages and push notifications to mobile clients at no charge. Mobile clients with the Ozeki App can use this gateway to send and receive messages. Click the installation link to start the setup process.

Install Ozeki chat account
Figure 2 - Install Ozeki chat account

Step 2 - Configure the Chat Account

Next, enter a workspace name that will act as the hostname for your chat server. After setting the workspace name, create a username and password for connecting to the chat network. Use the format user@domain for the username to ensure a unique identity within the network, allowing seamless message exchange. Click "Ok" to save these settings.

Provide chat account details
Figure 3 - Provide chat account details

After entering and confirming these details, the system will verify the connection. Once authentication is successful, your Ozeki Chat Gateway will be connected to the specified chat network. To enable communication between your gateway and mobile clients, switch the slider button to green. You will receive a notification about the successful connection in the events tab.

Chat connection established
Figure 4 - Chat connection established

Step 3 - Install and Configure C# Script

Next, return to the main interface of the Ozeki Chat Gateway and go to the "Add new application or chatbot" panel. From there, you can integrate new applications or chatbots with your Ozeki Chat Gateway.

Add application or chatbot
Figure 5 - Add application or chatbot

Install the C# script application form the connections panel. You can write a script, that allows you to run C# .NET code when a message arrives. This script can implement any logic to do various tasks with the incoming messages, and optionally send response messages. Click on the "Install" link to begin the installation.

Install C# script
Figure 6 - Install C# script

Now, configure C# script by specifying a unique connection name. Provide the source of your script you wish to execute. This setup will allow your script to run smoothly and efficiently within the designated environment. Once you are done, save these configurations by clicking on th "Ok" button.

Configure C# script
Figure 7 - Configure C# script

After entering and confirming the required details, the system will proceed to verify the connection. Upon successful authentication, your Ozeki Chat Gateway will be linked to the chosen chat network. To enable communication between your Ozeki Chat Gateway and mobile clients, simply switch the slider to the green position. A confirmation message will appear in the events tab, confirming that the connection has been successfully established.

Enable C# script connection
Figure 8 - Enable C# script connection

Step 4 - Define Message Routes

Next, return to the main interface and select the "Add new route" option. This route will determine how incoming messages are processed and directed within your system.

Add new incoming route
Figure 9 - Add new incoming route

You'll need to configure the incoming route, which will manage how messages and calls are transferred between connections. Begin by assigning a unique name to this route, then adjust the required settings. Specify the sender and receiver addresses to define the message path. After completing the configuration, click "OK" to save the route settings.

Configure incoming route
Figure 10 - Configure incoming route

To create a new outgoing route, select the "Add new route" option. This setup will control how outgoing messages are handled and sent to their recipients. Ensure that all required information, including routing criteria and destination settings, is completed before finalizing the configuration.

Add new outgoing route
Figure 11 - Add new outgoing route

Configure the outgoing route to manage how messages and calls are transferred between connections. Start by giving the route a unique name, then adjust the necessary settings. Define the message path by specifying the sender and receiver addresses. Once all details are set, click "OK" to save the route configuration.

Configure outgoing route
Figure 12 - Configure outgoing route

Step 5 - Testing C# Script

Load myozeki.com on your browser, and navigate to the chat conversations panel. If you receive a message, your system will automatically reply with the response defined by the C# script. The script will handle the message according to the logic you’ve configured, ensuring that your responses are sent without manual intervention.

Messages and answeres
Figure 13 - Messages and answeres

Conclusion

Sending chat messages using C# script in the Ozeki Chat Gateway is a straightforward process once the system is set up. By following the steps outlined, you can easily configure chat accounts, set up message routes, and integrate C# scripts to automate messaging tasks. The flexibility of C# scripting allows you to handle incoming and outgoing messages efficiently, providing seamless communication with mobile clients.

FAQs

What is the purpose of defining incoming and outgoing routes?

Incoming and outgoing routes are used to manage how messages are received and sent within the system, ensuring that messages follow the correct path and reach the intended recipients.

How can I check if my C# script is working correctly?

You can verify if the C# script is working by sending test messages and checking if the automated responses are as expected. Additionally, monitor the events tab for any notifications or errors.

What programming knowledge is required to use C# scripts with Ozeki Chat Gateway?

Basic understanding of C# programming is required to write and configure scripts for automating tasks and handling messages.

Can I use C# scripts for both text and multimedia messages?

Yes, C# scripts can be configured to handle various types of messages, including text and multimedia, depending on how the script is written.

More information