Skip to content

Commit f0ecc4e

Browse files
devlooped-botkzu
authored andcommitted
+Mᐁ includes
1 parent 00eaee0 commit f0ecc4e

File tree

1 file changed

+104
-1
lines changed

1 file changed

+104
-1
lines changed

src/Console/readme.md

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,105 @@
11
<!-- include ../../readme.md#cli -->
2-
<!-- include https://github.com/devlooped/sponsors/raw/main/footer.md -->
2+
<!-- #cli -->
3+
4+
Provides a command-line interface for the [WhatsApp](https://nuget.org/packages/Devlooped.WhatsApp)
5+
library and its backend functions. This allows you to interact with your WhatsApp pipeline without
6+
having to set up your WhatsApp for Business app for local development.
7+
8+
The backend functions are only enabled if the hosting environment is set to `Development` so that
9+
in production, the CLI endpoint is not available. Example with text format:
10+
11+
![](https://raw.githubusercontent.com/devlooped/WhatsApp/main/assets/img/cli-text.png)
12+
13+
Yaml format:
14+
15+
![](https://raw.githubusercontent.com/devlooped/WhatsApp/main/assets/img/cli-yaml.png)
16+
17+
JSON format:
18+
19+
![](https://raw.githubusercontent.com/devlooped/WhatsApp/main/assets/img/cli-json.png)
20+
21+
The console will automatically remember the last used WhatsApp endpoint, output format and simulated
22+
user phone number.
23+
24+
```bash
25+
Usage: whatsapp [OPTIONS]+
26+
Options:
27+
-u, --url WhatsApp functions endpoint
28+
-n, --number=VALUE Your WhatsApp user phone number
29+
-j, --json Format output as JSON
30+
-t, --text Format output as text
31+
-y, --yaml Format output as YAML
32+
-?, -h, --help Display this help.
33+
-v, --version Render tool version and updates.
34+
```
35+
36+
to render the responses since it provides a more readable format than JSON.
37+
38+
For non-text messages, the CLI falls short since you cannot attach files or images. For these
39+
cases, you can continue to send messages via WhatsApp, but get the responses also in the CLI.
40+
This works by inspecting messages in the current conversation (so it depends on `UseConversation`)
41+
and detecting if any messages were sent by the CLI. If that is the case, non-console messages
42+
will generate responses for the CLI as well:
43+
44+
```csharp
45+
builder.Services.AddWhatsApp<MyWhatsAppHandler>()
46+
.UseOpenTelemetry(builder.Environment.ApplicationName)
47+
.UseConversation()
48+
.UseConsole() // 👈 Enable CLI support for WhatsApp-originated messages
49+
50+
```
51+
52+
> [!IMPORTANT]
53+
> `UseConsole` will only be added to the pipeline if the hosting environment is set to `Development`,
54+
> so it's not necessary to check for that in your code. This is to ensure that the CLI behaviors
55+
> never impact production environments.
56+
57+
<!-- #cli -->
58+
<!-- ../../readme.md#cli -->
59+
<!-- include https://github.com/devlooped/sponsors/raw/main/footer.md -->
60+
# Sponsors
61+
62+
<!-- sponsors.md -->
63+
[![Clarius Org](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/clarius.png "Clarius Org")](https://github.com/clarius)
64+
[![MFB Technologies, Inc.](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/MFB-Technologies-Inc.png "MFB Technologies, Inc.")](https://github.com/MFB-Technologies-Inc)
65+
[![Torutek](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/torutek-gh.png "Torutek")](https://github.com/torutek-gh)
66+
[![DRIVE.NET, Inc.](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/drivenet.png "DRIVE.NET, Inc.")](https://github.com/drivenet)
67+
[![Keith Pickford](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/Keflon.png "Keith Pickford")](https://github.com/Keflon)
68+
[![Thomas Bolon](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/tbolon.png "Thomas Bolon")](https://github.com/tbolon)
69+
[![Kori Francis](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/kfrancis.png "Kori Francis")](https://github.com/kfrancis)
70+
[![Toni Wenzel](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/twenzel.png "Toni Wenzel")](https://github.com/twenzel)
71+
[![Uno Platform](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/unoplatform.png "Uno Platform")](https://github.com/unoplatform)
72+
[![Reuben Swartz](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/rbnswartz.png "Reuben Swartz")](https://github.com/rbnswartz)
73+
[![Jacob Foshee](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/jfoshee.png "Jacob Foshee")](https://github.com/jfoshee)
74+
[![](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/Mrxx99.png "")](https://github.com/Mrxx99)
75+
[![Eric Johnson](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/eajhnsn1.png "Eric Johnson")](https://github.com/eajhnsn1)
76+
[![David JENNI](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/davidjenni.png "David JENNI")](https://github.com/davidjenni)
77+
[![Jonathan ](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/Jonathan-Hickey.png "Jonathan ")](https://github.com/Jonathan-Hickey)
78+
[![Charley Wu](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/akunzai.png "Charley Wu")](https://github.com/akunzai)
79+
[![Ken Bonny](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/KenBonny.png "Ken Bonny")](https://github.com/KenBonny)
80+
[![Simon Cropp](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/SimonCropp.png "Simon Cropp")](https://github.com/SimonCropp)
81+
[![agileworks-eu](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/agileworks-eu.png "agileworks-eu")](https://github.com/agileworks-eu)
82+
[![Zheyu Shen](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/arsdragonfly.png "Zheyu Shen")](https://github.com/arsdragonfly)
83+
[![Vezel](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/vezel-dev.png "Vezel")](https://github.com/vezel-dev)
84+
[![ChilliCream](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/ChilliCream.png "ChilliCream")](https://github.com/ChilliCream)
85+
[![4OTC](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/4OTC.png "4OTC")](https://github.com/4OTC)
86+
[![Vincent Limo](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/v-limo.png "Vincent Limo")](https://github.com/v-limo)
87+
[![Jordan S. Jones](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/jordansjones.png "Jordan S. Jones")](https://github.com/jordansjones)
88+
[![domischell](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/DominicSchell.png "domischell")](https://github.com/DominicSchell)
89+
[![Justin Wendlandt](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/jwendl.png "Justin Wendlandt")](https://github.com/jwendl)
90+
[![Adrian Alonso](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/adalon.png "Adrian Alonso")](https://github.com/adalon)
91+
[![Michael Hagedorn](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/Eule02.png "Michael Hagedorn")](https://github.com/Eule02)
92+
[![Alex Rønne Petersen](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/alexrp.png "Alex Rønne Petersen")](https://github.com/alexrp)
93+
[![](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/henkmartijn.png "")](https://github.com/henkmartijn)
94+
[![Sebastien Lebreton](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/sailro.png "Sebastien Lebreton")](https://github.com/sailro)
95+
[![torutek](https://raw.githubusercontent.com/devlooped/sponsors/main/.github/avatars/torutek.png "torutek")](https://github.com/torutek)
96+
97+
98+
<!-- sponsors.md -->
99+
100+
[![Sponsor this project](https://raw.githubusercontent.com/devlooped/sponsors/main/sponsor.png "Sponsor this project")](https://github.com/sponsors/devlooped)
101+
&nbsp;
102+
103+
[Learn more about GitHub Sponsors](https://github.com/sponsors)
104+
105+
<!-- https://github.com/devlooped/sponsors/raw/main/footer.md -->

0 commit comments

Comments
 (0)